package state.before;

/**
 * @Author: Doream
 * @Date: 2022/1/30 10:36
 */
public class Lift implements ILift {
    private int state;

    @Override
    public void setState(int state) {
        this.state = state;
    }

    @Override
    public void open() {
        switch (state) {
            case OPENING_STATE:
                break;
            case CLOSEING_STATE:
                System.out.println("电梯打开了。");
                setState(OPENING_STATE);
                break;
            case RUNNING_STATE:
                break;
            case STOPING_STATE:
                System.out.println("电梯打开了。");
                setState(OPENING_STATE);
                break;
        }
    }

    @Override
    public void close() {
        switch (state) {
            case OPENING_STATE:
                System.out.println("电梯关闭了。");
                setState(CLOSEING_STATE);
                break;
            case CLOSEING_STATE:
                break;
            case RUNNING_STATE:
                break;
            case STOPING_STATE:
                System.out.println("电梯关闭了。");
                setState(CLOSEING_STATE);
                break;
        }
    }

    // TODO -- 以下代码还需修改
    @Override
    public void run() {
        switch (state) {
            case OPENING_STATE:
                break;
            case CLOSEING_STATE:
                System.out.println("电梯打开了。");
                setState(OPENING_STATE);
                break;
            case RUNNING_STATE:
                break;
            case STOPING_STATE:
                System.out.println("电梯打开了。");
                setState(OPENING_STATE);
                break;
        }
    }

    @Override
    public void stop() {
        switch (state) {
            case OPENING_STATE:
                break;
            case CLOSEING_STATE:
                System.out.println("电梯打开了。");
                setState(OPENING_STATE);
                break;
            case RUNNING_STATE:
                break;
            case STOPING_STATE:
                System.out.println("电梯打开了。");
                setState(OPENING_STATE);
                break;
        }
    }
}
